/************************************\
|* cardtest2.c                      *|
|* By Danny Burrows                 *|
|* burrowsd@onid.oregonstate.edu    *|
|* CS362 - Spring 2014              *|
|*                                  *|
|* Assignment 3                     *|
|*                                  *|
|* Unit testing of the drawCutPurse *|
\************************************/

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "dominion.h"

void checkTest(char *string, int expected, int result)
{
	if (expected == result)
		printf("PASS - %s: expected - %d, result - %d\n", string, expected, result);
	else
		printf("FAIL - %s: expected - %d, result - %d\n", string, expected, result);

	return;
}

void initGame(struct gameState *game)
{
	int *k = malloc(sizeof(int) * 10);
	int seed = rand() % (INT_MAX - 1) + 1;
	k = kingdomCards(0,1,2,3,4,5,6,7,8,9); // kindom cards required, if these values change, most of the tests fail
	initializeGame(2, k, seed, game); // must have an initialized game state

	return;
}

void runTests(struct gameState *game)
{
	int currentPlayer = 1;

	checkTest("hand size", 5, game->handCount[0]);
	checkTest("coins", 4, game->coins);

	drawCutPurseCard(currentPlayer, game, 0);
	checkTest("hand size", 4, game->handCount[0]);
	checkTest("coins", 6, game->coins);

	drawCutPurseCard(currentPlayer, game, 0);
	checkTest("hand size", 3, game->handCount[0]);
	checkTest("coins", 8, game->coins);


	return;
}

int main(int argc, char const *argv[])
{
	struct gameState *game = malloc(sizeof(struct gameState));

	initGame(game);
	
	runTests(game);

	free(game);

	return 0;
}